# 为了导入父目录文件进行的设定（源代码需要，此处不需要）
# import sys, os
# sys.path.append(os.pardir) 

import numpy as np
from mnist import load_mnist
from PIL import Image

def img_show(img):
    pil_img = Image.fromarray(np.uint8(img))
    pil_img.show()

(x_train, t_train), (x_test, t_test) = load_mnist(normalize=False, 
                                                  flatten=True)

# 读取第一张图像的标签
img = x_train[0]
label = t_train[0]
print(label)

img_show(img)
print(img.shape)    # 打印展平后的形状
img = img.reshape(28, 28)
print(img.shape)    # 打印图像重设后的形状

img_show(img)